FROM ubuntu:16.04
MAINTAINER ccoke
# 安装工具、服务和依赖
RUN apt-get -y update
RUN apt-get -y install vim dbus net-tools inetutils-ping gcc rsyslog
RUN apt-get -y install postfix postfix-mysql postfix-doc
RUN apt-get -y install dovecot-common dovecot-imapd dovecot-pop3d dovecot-mysql
# 创建用户组与用户
RUN groupadd -g 5000 vmail
RUN useradd -g vmail -u 5000 vmail -d /home/vmail -m
# 配置postfix
ADD ./postfix/filter/lib/libcjson.so /usr/local/lib
RUN ldconfig
ADD ./postfix/filter /etc/postfix/filter
WORKDIR /etc/postfix/filter
RUN ./build.sh
RUN mv filter.o* filter.o
RUN cp filter.o ..
RUN chmod a+x /etc/postfix/filter.o
ADD ./postfix/bounce.cf /etc/postfix
ADD ./postfix/main.cf /etc/postfix
ADD ./postfix/master.cf /etc/postfix
ADD ./postfix/mysql-virtual_domains.cf /etc/postfix
ADD ./postfix/mysql-virtual_email2email.cf /etc/postfix
ADD ./postfix/mysql-virtual_mailboxes.cf /etc/postfix
RUN chmod a+x /etc/postfix/mysql-virtual_*.cf
# 配置dovecot
WORKDIR /home/vmail
RUN mkdir log temp
RUN touch log/dovecot-debug.log log/dovecot-deliver.log log/dovecot-info.log
ADD ./dovecot/dovecot.conf /etc/dovecot
ADD ./dovecot/dovecot-sql.conf /etc/dovecot
ADD ./dovecot/dovecot-sql2.conf /etc/dovecot
# 添加执行脚本
ADD start.sh /opt
# 配置权限
RUN chown -R postfix:postfix /etc/postfix
RUN chown root:root /etc/postfix/dynamicmaps.cf
RUN chown -R vmail:vmail /home/vmail
# 申明端口号
EXPOSE 25
EXPOSE 143
EXPOSE 110
EXPOSE 993
EXPOSE 465
## 启动时执行命令
CMD ["sh", "/opt/start.sh"]